#define interface struct

//===========================================================================
// ISocketClient
//===========================================================================
interface ISocketClient
{
    virtual unsigned int GetSocket( void ) = 0;
    virtual unsigned int GetId( void ) = 0;
    virtual unsigned int GetIp( void ) = 0;
};

//===========================================================================
// ISocketClient
//===========================================================================
interface ISocketBuffer
{
    virtual void * GetPtr( void ) = 0;
    virtual unsigned int GetSize( void ) = 0;
};

//===========================================================================
// ISocket
//===========================================================================
interface ISocket
{
    virtual bool Disconnect( void ) = 0;
    
    virtual bool Send(
        unsigned int bytes,
        void *       data
    );
    
    virtual void EnableNagling(
        bool enable
    ) = 0;
};

//===========================================================================
// ISocketClient
//===========================================================================
interface ISocketClient
{
    virtual ISocket * OnConnected( void ) = 0;
    
    virtual void OnDisconnected( ISocket * socket ) = 0;
    
    virtual bool OnRead(
        ISocket *      socket,
        unsigned int   bytes,
        void *         data,
        unsigned int * processed
    );
};

//===========================================================================
bool SocketConnect(
    ISocketClient * client,
    unsigned int    address,
    unsigned int    portk
);

//===========================================================================
// IIocpSocketServer
//===========================================================================
interface IIocpSocketServer
{
    virtual bool Initialize(
        unsigned int port,
        unsigned int threads,
        unsigned int clients
    ) = 0;

    virtual bool StartUp( void ) = 0;
    virtual bool Stop(    void ) = 0;
    virtual bool Stoped(  void ) = 0;
    
    virtual void OnConnected(
        ISocketClient * client
    ) = 0;
    
    virtual void OnRead(
        ISocketClient * client,
        ISocketBuffer * buffer
    ) = 0;
        
    virtual void Disconnect(
        ISocketClient * client
    ) = 0;
    
    virtual void OnDisconnected(
        ISocketClient * socket
    ) = 0;

};

//===========================================================================
IIocpSocketServer * InitializeIocpSocketClient(
    unsigned int port,
    unsigned int threads,
    unsigned int clients
);